/*
 * Copyright (C) 2001-2005 Pleasant nightmare studio
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package org.pleasantnightmare.noraxidium.collision;

import org.apache.log4j.Logger;
import org.pleasantnightmare.noraxidium.math.GameVector2f;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Stores result of collision between CollisionBounds
 *
 * @author deus
 * @version 1.0
 * @see CollisionBound CollisionBound
 * @since Jul 9, 2010 2:21:47 PM
 */
public class CollisionResult {
  private static final Logger LOGGER = Logger.getLogger(CollisionResult.class);

  private Map<CollisionBound, GameVector2f> bounds;


  public CollisionResult() {
  }

  public void addBound(CollisionBound collisionBound, GameVector2f exitVector) {
    if (bounds == null)
      bounds = new HashMap<CollisionBound, GameVector2f>();
    bounds.put(collisionBound, exitVector);
  }

  public boolean isCollisionDetected() {
    for (GameVector2f gameVector2f : bounds.values()) {
      if (gameVector2f.getX() != 0.0F || gameVector2f.getY() != 0.0F)
        return true;
    }
    return false;
  }

  public Set<CollisionBound> getBounds() {
    return bounds != null ? bounds.keySet() : Collections.<CollisionBound>emptySet();
  }

  public GameVector2f getExitVector(CollisionBound collisionBound) {
    return bounds != null ? bounds.get(collisionBound) : null;
  }
}
